/******************************************************************************
 * The contents of this file are subject to the   JDI License  Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * The Initial Developer of the Original Code is 陈慧然. Portions created by 
 * 陈慧然 are Copyright 陈慧然.
 * All Rights Reserved.
 *
 *              Contact john_holen@163.com for licensing alternatives.
 *
 *****************************************************************************/


package org.peony.client.web;

import org.peony.exceptions.RenderException;
import org.peony.standard.ui.SIContainer;
import org.peony.standard.ui.SILayOut;
import org.peony.tools.StringUtil;

/**
 *  
 *
 *  @author     陈慧然
 *  @version    Id: WebContainer.java, v 0.000 2008-4-23 下午06:15:16 陈慧然 Exp
 */
public class WebContainer implements SIContainer{
	private static final String empty = StringUtil.empty;
	private SILayOut layout;
	private String css = empty;
	private String id = empty;
	
	public void clear() {
		layout = null;
	}

	public String getId() {
		return id;
	}

	public SILayOut getLayOut() {
		return layout;
	}

	public String getUIClass() {
		return css;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setLayOut(SILayOut layout) {
		this.layout = layout;
	}

	public void setUIClass(String css) {
		this.css = css;
	}

	public String toStandardString() throws RenderException {
		if(StringUtil.isEmpty(id))
			throw new RenderException("Container Can NOT has no id!");
		StringBuffer sb = new StringBuffer();
		sb.append("<div").append(StringUtil.isNotEmpty(getUIClass())?" class=\"" + getUIClass() + "\">":">");
		sb.append(getLayOut()==null?empty:getLayOut().toStandardString());
		sb.append("</div>");
		return sb.toString();
	}

}
